package org.sunshine.ueditor.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.baidu.ueditor.util.UploadBasePathUtil;

@Configuration
public class UEditorConfig implements WebMvcConfigurer{
	
	@Autowired
	private Environment env;

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		
		String uploadPath = UploadBasePathUtil.findUploadBasePath(env);
		
		String[] location = {"classpath:/META-INF/resources/",
				"classpath:/resources/","classpath:/static/","classpath:/public/",
				 "file:" + uploadPath};
		registry.addResourceHandler("/**").addResourceLocations(location);
	}
	
	

}
